package org.cy.websocket.stomp;

import org.cy.websocket.stomp.events.OnUnsubscribeEvent;

/**
 * created in 2021/5/12
 *
 * @author cao.yong
 */
public class StompSubscription {

    /**
     * Id associated with this subscription.
     */
    private final String id;

    /**
     * 取消订阅函数
     */
    private final OnUnsubscribeEvent onUnsubscribeEvent;

    public StompSubscription(String id, OnUnsubscribeEvent onUnsubscribeEvent) {
        this.id = id;
        this.onUnsubscribeEvent = onUnsubscribeEvent;
    }

    public String getId() {
        return id;
    }

    public void unsubscribe(StompHeaders headers) {
        this.onUnsubscribeEvent.on(headers);
    }
}
